import axios from 'axios';
var CancelToken = axios.CancelToken;
var cancel;
const service = axios.create({
	// process.env.NODE_ENV === 'development' 来判断是否开发环境
	// easy-mock服务挂了，暂时不使用了
	baseURL: 'http://careapi.miwitracker.com/',
	timeout: 5000,
	headers: {
	   'Content-Type': 'application/json',
	    // 'Host': 'http://careapi.miwitracker.com'
	}
});
// 可通过axios.defaults.headers.dddd = 123;设置全局默认

service.interceptors.request.use(
	config => {
		return config;
	},
	error => {
		console.log(error);
		return Promise.reject();
	}
);

service.interceptors.response.use(
	response => {
		if (response.status === 200) {
			return response.data;
		} else {
			Promise.reject();
		}
	},
	error => {
		// console.log(error);
		return Promise.reject();
	}
);

export default service;
